#include "../lib/ls1c_public.h"
#include "../lib/ls1c_irq.h"
#include "../lib/ls1c_gpio.h"
#include "../lib/ls1c_delay.h"
#include "../lib/ls1c_mipsregs.h"
#include "../lib/ls1c_uart.h"
#include "../lib/ls1c_sys_tick.h"
#include "../lib/ls1c_clock.h"
#include "oled_ssd1306_i2c.h"
#include "esp8266.h"
#include "test_simulate_i2c.h"
#include "test_gpio.h"


// 硬浮点初始化
void fpu_init(void)
{
    unsigned int c0_status = 0;
    unsigned int c1_status = 0;

    // 使能协处理器1--FPU
    c0_status = read_c0_status();
    c0_status |= (ST0_CU1 | ST0_FR);
    write_c0_status(c0_status);

    // 配置FPU
    c1_status = read_c1_status();
    c1_status |= (FPU_CSR_FS | FPU_CSR_FO | FPU_CSR_FN);    // set FS, FO, FN
    c1_status &= ~(FPU_CSR_ALL_E);                          // disable exception
    c1_status = (c1_status & (~FPU_CSR_RM)) | FPU_CSR_RN;   // set RN
    write_c1_status(c1_status);

    return ;
}



void bsp_init(void)
{
    // 初始化调试串口
    uart2_init();
    
    // 硬浮点初始化
    fpu_init();

    // 初始化异常
    exception_init();

    // 显示时钟信息
    clk_print_all();

    return ;
}



int main(void)
{
    int line=21;
	bsp_init();
    // 注意内存的大小，在文件sdram_cfg.h中配置内存大小，

    oled_init();


    while (1)
    {
          oled_show();
    	  test_i2c_am2320();//温度传感器

                //OLED 屏幕显示数据




          test_fire_irq();//火焰警报

          test_qiti_irq();//气体触发中断



    	   RC522main();
			if(line % 30==0)
			{
				esp8266_config();
			}

			line++;
			printf("%d", line);

    }

	return(0);
}





